<?php
    include 'base.php';

    $pagenum = $_GET['pagenum'];
    $totalpage = $_GET['totalpage'];

    $start = ($pagenum - 1) * $totalpage;

    $sql = "SELECT * FROM `goods` LIMIT $start, $totalpage";

    $res = $conn -> query($sql);

    $arr = array();

    while($row = mysqli_fetch_assoc($res)) {
        array_push($arr, $row);
    }

    // 查看数据量
    $sql2 = "SELECT * FROM `banner`";
    $res2 = $conn -> query($sql2);
    $count = 0;
    while($row2 = mysqli_fetch_assoc($res2)) {
        $count++;
    }
    // echo $count;


    // echo json_encode($arr);

    echo json_encode(array(
        'totol' => $count,
        'data' => $arr,
        'count' => $count / $totalpage
    ));
?>